package com.example.myapplication.Action;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

import com.example.myapplication.R;

public class ActionDemoActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_action_demo);
    }

    public void onClick(View view) {

        if(view.getId()==R.id.actionButton1){
            Intent intent = new Intent(Intent.ACTION_VIEW);
            ///打开网页
            intent.setData(Uri.parse("http://www.baidu.com"));
            startActivity(intent);
        }
        if(view.getId()==R.id.actionButton2){
            Intent intent = new Intent(Intent.ACTION_VIEW);
            ///打开通讯录
            intent.setData(Uri.parse("content://com.android.contacts/contacts"));
            startActivity(intent);
        }
        if(view.getId()==R.id.actionButton3){
            Intent intent = new Intent(Intent.ACTION_VIEW);
            ///打开通讯录第一个联系人
            ///BUG:无法打开
            intent.setData(Uri.parse("content://com.android.contacts/contacts/1"));
            startActivity(intent);
        }
        if(view.getId()==R.id.actionButton4){
            ///打开指定类型的应用
            Intent intent = new Intent();
            intent.setAction("android.intent.action.MAIN");
            ///打开日历
            intent.addCategory("android.intent.category.APP_CALENDAR");
            startActivity(intent);
        }

    }
}